﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace LitTools
{
    /// <summary>
    /// 节点基类
    /// </summary>
    public abstract class BTNode
    {
        public string name;
        private BTNodeState state;
        private bool started;

        public BTNodeState Update()
        {
            if (!started)
            {
                OnStart();
                started = true;
            }
            state = OnUpdate();
            if (state != BTNodeState.Running)
            {
                OnStop();
                started = false;
            }
            //Debug.Log($"name:{name} state:{state}");
            return state;
        }

        #region 抽象方法
        protected abstract void OnStart();
        protected abstract BTNodeState OnUpdate();
        protected abstract void OnStop();
        #endregion
    }

    /// <summary>
    /// 行为节点
    /// </summary>
    public abstract class BTNode_Action : BTNode
    {

    }

    /// <summary>
    /// 装饰节点
    /// 处理子节点的返回结果
    /// </summary>
    public abstract class BTNode_Deocrator : BTNode
    {
        public BTNode child;
    }

    /// <summary>
    /// 组合节点
    /// </summary>
    public abstract class BTNode_Composite : BTNode
    {
        public List<BTNode> children;
    }
}